package com.fiberhome.nas.feature.album.navigation

import androidx.compose.animation.ExperimentalSharedTransitionApi
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import com.fiberhome.nas.core.model.entity.AlbumInfo
import com.fiberhome.nas.feature.album.view.AlbumDetailRoute
import com.fiberhome.nas.feature.common.serializable.serializableNavType
import com.fiberhome.nas.navigation.routes.AlbumRoutes

object AlbumDetailRoutes {
    const val ALBUM_ITEM = "albumItem"
}

@OptIn(ExperimentalSharedTransitionApi::class)
fun NavGraphBuilder.albumDetailScreen() {
    composable(
        route = "${AlbumRoutes.DETAIL}/{${AlbumDetailRoutes.ALBUM_ITEM}}",
        arguments = listOf(
            navArgument(AlbumDetailRoutes.ALBUM_ITEM) {
                type = serializableNavType<AlbumInfo>()
                nullable = false
            }
        )
    ) {
        val argument = requireNotNull(it.arguments)
        val albumInfo = argument.getSerializable(AlbumDetailRoutes.ALBUM_ITEM) as AlbumInfo
        AlbumDetailRoute()
    }


    composable(AlbumRoutes.DETAIL) {
        AlbumDetailRoute()
    }
}